<?php
include($_SERVER["DOCUMENT_ROOT"] . "/bob.php");
include($_SERVER["DOCUMENT_ROOT"] . "/forum/fonctions_forum.php");
$mysqli = new_mysqli($host, $user, $password, $database); //connection à la DB


$variable_get = filter_input_array(INPUT_GET);
$variable_post = filter_input_array(INPUT_POST);
?>
<!DOCTYPE html>
<html lang="fr" dir="ltr">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="Content-Language" content="fr">
        <meta name="language" content="fr"/>  
        <script type='text/javascript' src="/js/menu.js"></script>
        <script type='text/javascript' src="/js/phw-lib.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" ></script>    
        <link href='http://fonts.googleapis.com/css?family=Economica:700' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" type="text/css" href="/css/main.css" />
        <link rel="stylesheet" type="text/css" href="/css/menu.css" />
        <link rel="stylesheet" type="text/css" href="/css/forum.css" />
        <link rel="stylesheet" type="text/css" href="/css/popup.css" />

    </head>
    <body>

            <div id="avatars">
                <?php
                $rqt_avatars="SELECT * FROM portraits_debloques as pd LEFT JOIN portraits as p ON p.id=pd.portrait_id WHERE pd.user_id=".$_SESSION['id'];
                $result=  mysqli_query_with_error($mysqli, $rqt_avatars);
                
                $dirname = "../../jeu/avatars/";

               
                $id = 0;
                while ($avatar = $result->fetch_assoc()) {                   
                        echo "<div class='avatar'>";
                        echo get_avatar($avatar['chemin'], $variable_get['idcouleur'], 'avatar' . $id, $dirname, 90);
                        ?>
                        <script>
                            $('#avatar' +<?php echo $id ?>).click(function() {
                                $('#avatar_profil', window.parent.document).attr('src',"../jeu/avatars/<?php echo $avatar['chemin'] ?>");
                                $('#chemin_avatar', window.parent.document).attr('value','<?php echo $avatar['chemin'] ?>');
                                $('#chemin_avatar_min', window.parent.document).attr('value','<?php echo $avatar['chemin_min'] ?>');
                                //$('#avatar_profil', window.parent.document).attr('src',"../jeu/avatars/<?php echo $avatar['chemin'] ?>");
                                
                                parent.masquer_popup();
                            });
                            //parent.masquer_popup();

                        </script>
                        <?php
                        echo '</div>';
                    
                    $id++;
                }
              
                ?>
            </div>
            <h3>Sélectionnez un avatar</h3>
       
       
    </body>
</html>
